ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
SBC_AL.h File Reference

System basis chip abstraction layer for airbag application. Upper layers shouldn't talk directly with the SBC driver to avoid file dependencies in the application. More...

Go to the source code of this file.

Defines

#define TRUE   (1u)
#define CLEAR   (0u)
#define BITS_IN_BYTE   (8u)
#define BYTES_IN_16   (2u)
#define BYTES_IN_32   (4u)
#define BIT_DEFINITION
#define BIT0   (1u << 0u)
#define BIT1   (1u << 1u)
#define BIT2   (1u << 2u)
#define BIT3   (1u << 3u)
#define BIT4   (1u << 4u)
#define BIT5   (1u << 5u)
#define BIT6   (1u << 6u)
#define BIT7   (1u << 7u)
#define BIT8   (1u << 8u)
#define BIT9   (1u << 9u)
#define BIT10   (1u << 10)
#define BIT11   (1u << 11)
#define BIT12   (1u << 12)
#define BIT13   (1u << 13)
#define BIT14   (1u << 14)
#define BIT15   (1u << 15)
#define BIT16   (1u << 16)
#define BIT17   (1u << 17)
#define BIT18   (1u << 18)
#define BIT19   (1u << 19)
#define BIT20   (1u << 20)
#define BIT21   (1u << 21)
#define BIT22   (1u << 22)
#define BIT23   (1u << 23)
#define BIT24   (1u << 24)
#define BIT25   (1u << 25)
#define BIT26   (1u << 26)
#define BIT27   (1u << 27)
#define BIT28   (1u << 28)
#define BIT29   (1u << 29)
#define BIT30   (1u << 30)
#define BIT31   (1u << 31)
#define SQUIB_CH0_PRESENT   (BIT0)
#define SQUIB_CH0_ABSENT   (0u)
#define SQUIB_CH1_PRESENT   (BIT1)
#define SQUIB_CH1_ABSENT   (0u)
#define SQUIB_CH2_PRESENT   (BIT2)
#define SQUIB_CH2_ABSENT   (0u)
#define SQUIB_CH3_PRESENT   (BIT3)
#define SQUIB_CH3_ABSENT   (0u)
#define SQUIB_CH4_PRESENT   (BIT4)
#define SQUIB_CH4_ABSENT   (0u)
#define SQUIB_CH5_PRESENT   (BIT5)
#define SQUIB_CH5_ABSENT   (0u)
#define SQUIB_CH6_PRESENT   (BIT6)
#define SQUIB_CH6_ABSENT   (0u)
#define SQUIB_CH7_PRESENT   (BIT7)
#define SQUIB_CH7_ABSENT   (0u)
#define SQUIB_CH8_PRESENT   (BIT8)
#define SQUIB_CH8_ABSENT   (0u)
#define SQUIB_CH9_PRESENT   (BIT9)
#define SQUIB_CH9_ABSENT   (0u)
#define SQUIB_CH10_PRESENT   (BIT10)
#define SQUIB_CH10_ABSENT   (0u)
#define SQUIB_CH11_PRESENT   (BIT11)
#define SQUIB_CH11_ABSENT   (0u)
#define SAT_CH0_SLOT0_PRESENT   (BIT0)
#define SAT_CH0_SLOT0_ABSENT   (0u)
#define SAT_CH0_SLOT1_PRESENT   (BIT1)
#define SAT_CH0_SLOT1_ABSENT   (0u)
#define SAT_CH0_SLOT2_PRESENT   (BIT2)
#define SAT_CH0_SLOT2_ABSENT   (0u)
#define SAT_CH1_SLOT0_PRESENT   (BIT3)
#define SAT_CH1_SLOT0_ABSENT   (0u)
#define SAT_CH1_SLOT1_PRESENT   (BIT4)
#define SAT_CH1_SLOT1_ABSENT   (0u)
#define SAT_CH1_SLOT2_PRESENT   (BIT5)
#define SAT_CH1_SLOT2_ABSENT   (0u)
#define SAT_CH2_SLOT0_PRESENT   (BIT6)
#define SAT_CH2_SLOT0_ABSENT   (0u)
#define SAT_CH2_SLOT1_PRESENT   (BIT7)
#define SAT_CH2_SLOT1_ABSENT   (0u)
#define SAT_CH2_SLOT2_PRESENT   (BIT8)
#define SAT_CH2_SLOT2_ABSENT   (0u)
#define SAT_CH3_SLOT0_PRESENT   (BIT9)
#define SAT_CH3_SLOT0_ABSENT   (0u)
#define SAT_CH3_SLOT1_PRESENT   (BIT10)
#define SAT_CH3_SLOT1_ABSENT   (0u)
#define SAT_CH3_SLOT2_PRESENT   (BIT11)
#define SAT_CH3_SLOT2_ABSENT   (0u)
#define SQUIB_CH0_NOT_FIRED   CLEAR
#define SQUIB_CH1_NOT_FIRED   CLEAR
#define SQUIB_CH2_NOT_FIRED   CLEAR
#define SQUIB_CH3_NOT_FIRED   CLEAR
#define SQUIB_CH4_NOT_FIRED   CLEAR
#define SQUIB_CH5_NOT_FIRED   CLEAR
#define SQUIB_CH6_NOT_FIRED   CLEAR
#define SQUIB_CH7_NOT_FIRED   CLEAR
#define SQUIB_CH8_NOT_FIRED   CLEAR
#define SQUIB_CH9_NOT_FIRED   CLEAR
#define SQUIB_CH10_NOT_FIRED   CLEAR
#define SQUIB_CH11_NOT_FIRED   CLEAR
#define SAT_CH0_SLOT0_NOT_CRASHED   CLEAR
#define SAT_CH0_SLOT1_NOT_CRASHED   CLEAR
#define SAT_CH0_SLOT2_NOT_CRASHED   CLEAR
#define SAT_CH1_SLOT0_NOT_CRASHED   CLEAR
#define SAT_CH1_SLOT1_NOT_CRASHED   CLEAR
#define SAT_CH1_SLOT2_NOT_CRASHED   CLEAR
#define SAT_CH2_SLOT0_NOT_CRASHED   CLEAR
#define SAT_CH2_SLOT1_NOT_CRASHED   CLEAR
#define SAT_CH2_SLOT2_NOT_CRASHED   CLEAR
#define SAT_CH3_SLOT0_NOT_CRASHED   CLEAR
#define SAT_CH3_SLOT1_NOT_CRASHED   CLEAR
#define SAT_CH3_SLOT2_NOT_CRASHED   CLEAR
#define SAT_CH0_SLOT0_CRASHED   BIT0
#define SAT_CH0_SLOT1_CRASHED   BIT1
#define SAT_CH0_SLOT2_CRASHED   BIT2
#define SAT_CH1_SLOT0_CRASHED   BIT3
#define SAT_CH1_SLOT1_CRASHED   BIT4
#define SAT_CH1_SLOT2_CRASHED   BIT5
#define SAT_CH2_SLOT0_CRASHED   BIT6
#define SAT_CH2_SLOT1_CRASHED   BIT7
#define SAT_CH2_SLOT2_CRASHED   BIT8
#define SAT_CH3_SLOT0_CRASHED   BIT9
#define SAT_CH3_SLOT1_CRASHED   BIT10
#define SAT_CH3_SLOT2_CRASHED   BIT11
#define SBC_N_SATELLITES_POSSIBLE   12u
#define SBC_N_SQUIBS_POSSIBLE   12u
#define SBC_SENSOR_DATA_ARRAY_SIZE   264u
#define SBC_N_CONFIG_BUFFER_SIZE   60u
#define SBC_FIRED_SQUIB_MIN_TIME   0x8u
#define SBC_TEST_SBC_FAILED   BIT14
#define SBC_TEST_SAT_0   BIT0
#define SBC_TEST_SAT_1   BIT1
#define SBC_TEST_SAT_2   BIT2
#define SBC_TEST_SAT_3   BIT3
#define SBC_TEST_SAT_4   BIT4
#define SBC_TEST_SAT_5   BIT5
#define SBC_TEST_SAT_6   BIT6
#define SBC_TEST_SAT_7   BIT7
#define SBC_TEST_SAT_8   BIT8
#define SBC_TEST_SAT_9   BIT9
#define SBC_TEST_SAT_10   BIT10
#define SBC_TEST_SAT_11   BIT11
#define SBC_TEST_ALL_SAT   (BIT12 - 1u)
#define SBC_TEST_SQUIB_0   BIT16
#define SBC_TEST_SQUIB_1   BIT17
#define SBC_TEST_SQUIB_2   BIT18
#define SBC_TEST_SQUIB_3   BIT19
#define SBC_TEST_SQUIB_4   BIT20
#define SBC_TEST_SQUIB_5   BIT21
#define SBC_TEST_SQUIB_6   BIT22
#define SBC_TEST_SQUIB_7   BIT23
#define SBC_TEST_SQUIB_8   BIT24
#define SBC_TEST_SQUIB_9   BIT25
#define SBC_TEST_SQUIB_10   BIT26
#define SBC_TEST_SQUIB_11   BIT27
#define SBC_TEST_ALL_SQUIB   (BIT28 - 1u)
#define N_ELEMENTS(X)   (sizeof(X)/sizeof(*(X)))

Functions

uint8_t u8fnSBCPreSchedulerEnableWarningLamp (uint8_t u8Enable)
 This routine shall be called before the scheduler has been launched to turn on the warning lamp connected to the SBC.
uint8_t u8fnSBCEnableWarningLamp (uint8_t u8Enable)
 This routine shall be called after the scheduler has been launched to turn on the warning lamp connected to the SBC.
void vfnSBCPreSchedulerInit (void)
 This routine shall be called before the scheduler has been launched to initialize the SBC.
void vfnSBCResetPin (uint32_t u32State)
 Sets a logical level on the SBC's reset pin.
uint32_t u32fnSBCInit (void)
 This routine shall be called after the scheduler has been launched to initialize the SBC.
uint32_t u32fnSBCPerformInitialTests (void)
 This routine performs initial tests on the SBC at startup to guarantee operation. It includes POM, ADC, Mux, and FLM tests.
uint32_t u32fnSBCSchedulePSISat (uint16_t *pu16RawAccelArray)
 Schedules reading from all PSI5 satellites.
uint8_t u8fnSBCSchedulePSync (void)
 Schedules a synchronization pulse for synchronous PSI5 satellites. May not be necessary if the SBC is generating them automatically.
uint8_t u8fnSBCSyncSM (const uint8_t u8Period)
 Synchronizes the SBC to a given period with the watch-dog 2 as a reference clock. Necessary to guarantee accuracy regarding PSI5 sync pulses.
uint32_t u32fnSBCExtractPSISat (uint16_t *pu16RawAccelArray, uint16_t *pu16Filtered)
 Transforms raw data returned by satellites into usable data.
uint32_t u32fnSBCScheduleCmd (uint8_t u8Cmd, uint8_t u8Arg, uint16_t *pu16Response)
 Schedules a specific command to be sent.
uint32_t u32fnSBCFireSquibs (const uint16_t cu16SquibMask)
 Complete sequence of commands used to fire any number of squibs.
uint16_t u16fnSBCGatherPSI5SatelliteData (uint8_t *pu8PSI5Data)
 First, this function instructs the SBC to turn automatic Sync-pulse generation. Next, and according to the PSI5 standard, it captures all satellite initial data, places it into an array, and returns a status indicating if satellites are happy or not.
uint32_t u32fnSBCSquibFiringStatus (uint16_t *pu16Response)
 Reads back fire counter for all squibs. If anyone of them surpass a defined threshold (SBC_FIRED_SQUIB_MIN_TIME), they're flagged as "fired.".

Variables

uint32_t gu32SBCTime
uint16_t gu16ActivePSI5Channels
uint16_t gu16ActiveSquibChannels
uint16_t gu16FiredSquibs
uint16_t gu16SquibsToFire
uint16_t gu16CrashedSatellites
uint16_t gu16ConfirmedSatellites
uint8_t gu8SBCSatelliteData []
const uint16_t cu16PresentSquibs
const uint16_t cu16PresentSatellites

Detailed Description

System basis chip abstraction layer for airbag application. Upper layers shouldn't talk directly with the SBC driver to avoid file dependencies in the application.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
R54967
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint16_t u16fnSBCGatherPSI5SatelliteData ( uint8_t *  pu8PSI5Data)

First, this function instructs the SBC to turn automatic Sync-pulse generation. Next, and according to the PSI5 standard, it captures all satellite initial data, places it into an array, and returns a status indicating if satellites are happy or not.

Parameters:
pu8PSI5Data,:Pointer to an array where all satellites settings shall be stored. Each satellite requires n bytes, as defined in the MMA5100_REGISTER_INDEX within the MMA51xx interpreter file.
Returns:
u16Status: A combination of MMA5100_COMMAND_NOT_RECOGNIZED, MMA5100_SENSOR_BUSY_STATUS, MMA5100_SENSOR_DEFECT_STATUS, MMA5100_SENSOR_READY_UNLOCKED_STATUS, and/or MMA5100_SENSOR_READY_STATUS.
Note:
Current implementation assumes only MMA51xx satellites.
uint32_t u32fnSBCExtractPSISat ( uint16_t *  pu16RawAccelArray,
uint16_t *  pu16Filtered 
)

Transforms raw data returned by satellites into usable data.

Parameters:
pu16RawAccelArray,:pointer to where raw data is stored.
pu16Filtered,:Array of filtered data.
Returns:
CLEAR if all acceleration results were extracted correctly and their corresponding status was clear (refer to u8fnCG147ExtractPSIAccel); or a flag set for each channel that was not clear, from CG147_SAT_MASK_MIN to CG147_SAT_MASK_MAX.
uint32_t u32fnSBCFireSquibs ( const uint16_t  cu16SquibMask)

Complete sequence of commands used to fire any number of squibs.

Parameters:
cu16SquibMask,:Mask used to determine which squibs will be fired, justified right, following positive logic.
Returns:
u32Status: Clear if all ok; STATUS_SCHEDULER_PROBLEM if a problem was found writing to the device.
uint32_t u32fnSBCInit ( void  )

This routine shall be called after the scheduler has been launched to initialize the SBC.

Parameters:
None.
Returns:
u32Status: Clear if all ok, SBC_TEST_SCHEDULER_FAILED if a scheduler problem has been found, SBC_TEST_UNEXPECTED_SPI_RESULT if initial 16-bit configuration has not been performed successfully, SBC_TEST_ALL_SAT if satellites fail to initialize correctly, a mask for each satellite that has not been found according to cu16PresentSatellites (from BIT0 to BIT11), SBC_TEST_SBC_FAILED if any SBC test has failed.
uint32_t u32fnSBCPerformInitialTests ( void  )

This routine performs initial tests on the SBC at startup to guarantee operation. It includes POM, ADC, Mux, and FLM tests.

Parameters:
None.
Returns:
Zero if no problems; otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED; SBC_TEST_SCHEDULER_FAILED if there was a problem reading back from the scheduler; SBC_TEST_SBC_ADC_FAILED if the given test instance has failed; SBC_TEST_FLM_LEAK_FAILED if the selected test was high-leakage related and it was failed; SBC_TEST_FLM_LOWLEAK_FAILED if the selected test was low-leakage related and it was failed; SBC_TEST_FLM_RESISTANCE_FAILED if the resistance was outside the pre-established limits. All failed status words will contain a flag corresponding to the failed squibs; SBC_TEST_SBC_FAILED if ADC or MUX, or ERx tests are failed;
uint32_t u32fnSBCScheduleCmd ( uint8_t  u8Cmd,
uint8_t  u8Arg,
uint16_t *  pu16Response 
)

Schedules a specific command to be sent.

Parameters:
u8Cmd,:Command
u8Arg,:Argument to the command
pu16Response,:Pointer to array where the response shall be saved
Returns:
u32Status: Clear if all ok; STATUS_SCHEDULER_PROBLEM if a problem was found writing to the device.
uint32_t u32fnSBCSchedulePSISat ( uint16_t *  pu16RawAccelArray)

Schedules reading from all PSI5 satellites.

Parameters:
pu16RawAccelArray,:pointer to where raw data will be stored.
Returns:
u32Status: Clear if all ok, STATUS_SCHEDULER_PROBLEM if there has been a problem with the schedule.
uint32_t u32fnSBCSquibFiringStatus ( uint16_t *  pu16Response)

Reads back fire counter for all squibs. If anyone of them surpass a defined threshold (SBC_FIRED_SQUIB_MIN_TIME), they're flagged as "fired.".

Parameters:
pu16Response,:pointer to where the flags will be set. BIT0 to BIT11 are used as flags that are set in case the associated squib has been fired.
Returns:
u32Status: Clear if all ok, STATUS_SCHEDULER_PROBLEM if there has been an issue sending or decoding data to and from the SBC; STATUS_DATA_TRANSFER_ERROR if there has been an error in the response and it is deemed unreliable;
uint8_t u8fnSBCEnableWarningLamp ( uint8_t  u8Enable)

This routine shall be called after the scheduler has been launched to turn on the warning lamp connected to the SBC.

Parameters:
u8Enable,:If zero, disable, otherwise enable.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
uint8_t u8fnSBCPreSchedulerEnableWarningLamp ( uint8_t  u8Enable)

This routine shall be called before the scheduler has been launched to turn on the warning lamp connected to the SBC.

Parameters:
u8Enable,:If zero, disable, otherwise enable.
Returns:
u8Status: Zero if no problems found; 1 if the HW is busy and cannot transmit existing data.
uint8_t u8fnSBCSchedulePSync ( void  )

Schedules a synchronization pulse for synchronous PSI5 satellites. May not be necessary if the SBC is generating them automatically.

Parameters:
None
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
uint8_t u8fnSBCSyncSM ( const uint8_t  u8Period)

Synchronizes the SBC to a given period with the watch-dog 2 as a reference clock. Necessary to guarantee accuracy regarding PSI5 sync pulses.

Parameters:
u8Period,:number of scheduler periods to wait after the watch-dog has been sent to SBC.
Returns:
Always CLEAR.
void vfnSBCPreSchedulerInit ( void  )

This routine shall be called before the scheduler has been launched to initialize the SBC.

Parameters:
None.
Returns:
Void.
void vfnSBCResetPin ( uint32_t  u32State)

Sets a logical level on the SBC's reset pin.

Parameters:
u32State,:TRUE if the pin shall hold a high logical level; CLEAR otherwise.
Returns:
Void.

Variable Documentation

const uint16_t cu16PresentSatellites

Lists in order whether a satellite should be active in the system or not

const uint16_t cu16PresentSquibs

Lists in order whether a squib should be active in the system or not

Global variable that keeps in mind which are the active PSI5 channels

Global variable that keeps in mind which are the active squibs

Global that keeps track of satellites that have been confirmed crashed

Global that keeps track of satellites that have been crashed

uint16_t gu16FiredSquibs

Global variable that keeps track of fired squibs

uint16_t gu16SquibsToFire

Global variable that keeps track of squibs to be fired

uint32_t gu32SBCTime

Global variable that remembers last tick value for last SBC-based fn.